Checks files to ensure the md5 and/or SHA1 hash(es) match those the file is supposed to have.

Note: Requires supplied md5 and/or SHA1 hash(es) to check file's actual hash(es) against!

Put a file in the same directory as this script, have the correct hashes ready, supply them to the script, and click the check now button, and this script will tell you if it's correct.

Update: 1.1 > Added a check to see if the file exists.

==========================================================

<?php

/*****
File Hash Check Script
Written By: Valek
*****/

error_reporting(E_STRICT);


if(!$_POST['hashcheck']) {
	echo "<form name='hashcheck' method='post' action=''>\r\n
	File: <input type='text' name='file'><br />\r\n
	Valid SHA1 Hash: <input type='text' name='sha1check'><br />\r\n
	Valid md5 Hash: <input type='text' name='md5check'><br /><br />\r\n
	<input type='hidden' name='hashcheck' value='1'>
	<input type='submit' name='submit' value='Check Now'></form>";
}
else {
	extract($_POST,EXTR_OVERWRITE);
	
	if($file == '') {
		die("You must supply a file name!  Click back in your browser to try again.");
	}

	if($sha1check != '') {
		$sha1 = sha1_file($file) or die("File does not exist!");
		if($sha1 == $sha1check) {
			$sverdict = "<font color='green'><b>Verified</b></font>";
		}
		else if($sha1) {
			$sverdict = "<font color='red'><b>Invalid hash!</b></font>";
		}
	}
	if($md5check != '') {
		$md5 = md5_file($file) or die("File does not exist!");
		if($md5 == $md5check) {
			$mverdict = "<font color='green'><b>Verified</b></font>";
		}
		else if($md5) {
			$mverdict = "<font color='red'><b>Invalid hash!</b></font>";
		}
	}
	
	if($sha1check != '') {
		echo "SHA1 Hash Supplied: {$sha1check}<br />\r\nSHA1 Hash Returned: {$sha1}<br />\r\nVerdict: {$sverdict}\r\n<br /><br />\r\n";
	}
	if($md5check != '') {
		echo "md5 Hash Supplied: {$md5check}<br />\r\nmd5 Hash Returned: {$md5}<br />\r\nVerdict: {$mverdict}\r\n<br /><br />\r\n";
	}
	if(!$sha1check && !$md5check) {
		echo "No hashes supplied to check against!\r\n<br /><br />\r\n";
	}
	echo "<a href='javascript:history.go(-1)'>Click here to go back.</a>";
}

?>